package com.iflytek.speech;

import com.iflytek.speech.tts.ITtsListener;

/**
 * TTS引擎套件层接口说明
 */
public class libisstts {
    static {
        System.loadLibrary("issxtts");
        System.loadLibrary("issauth");
        System.loadLibrary("hardinfo");
        System.loadLibrary("lesl");
        System.loadLibrary("websockets");
    }

    ///< The code page of the input TTS text
    final public static int ISS_TTS_CODEPAGE_GBK            = (936);
    final public static int ISS_TTS_CODEPAGE_UTF16LE        = (1200);
    final public static int ISS_TTS_CODEPAGE_UTF8           = (65001);

    final public static int ISS_TTS_RES_MODE_FILE_HANDLE    = (0);              /*!< TTS Res load type. by file handle */
    final public static int ISS_TTS_RES_MODE_MEMORY         = (1);              /*!< TTS Res load type. load to memory */

    final public static int ISS_TTS_PARAM_SPEAKER           = (0x00000500);
    final public static int ivTTS_ROLE_XIAOYAN              = (3);              /**< Xiaoyan (female, Chinese) */
    final public static int ivTTS_ROLE_XIAOFENG             = (4);              /**< Xiaofeng (male, Chinese) */
    final public static int ivTTS_ROLE_NANNAN               = (7);              /**< Nannan (child, Chinese) */
    final public static int ivTTS_ROLE_XIAOJING             = (8);              /**< Xiaojing (female, Chinese) */
    final public static int ivTTS_ROLE_JIAJIA               = (9);              /**< Jiajia (girl, Chinese) */
    final public static int ivTTS_ROLE_XIAOQIAN             = (11);             /**< Xiaoqian (female, Chinese Northeast) */
    final public static int ivTTS_ROLE_LAOMA                = (12);             /**< Laoma (male, Chinese) */
    final public static int ivTTS_ROLE_XIAORONG             = (14);             /**< Xiaorong (female, Chinese Szechwan) */
    final public static int ivTTS_ROLE_XIAOMEI              = (15);             /**< Xiaomei (female, Cantonese) */
    final public static int ivTTS_ROLE_JOHN                 = (17);             /**< John (male, US English) */
    final public static int ivTTS_ROLE_TERRY                = (19);             /**< Terry (female, US English) */
    final public static int ivTTS_ROLE_CATHERINE            = (20);             /**< Catherine (female, US English) */
    final public static int ivTTS_ROLE_XIAOLIN              = (22);             /**< Xiaolin (female, Chinese) */
    final public static int ivTTS_ROLE_XIAOMENG             = (23);             /**< Xiaomeng (female, Chinese) */
    final public static int ivTTS_ROLE_XIAOQIANG            = (24);             /**< Xiaoqiang (male, Chinese) */
    final public static int ivTTS_ROLE_XIAOKUN              = (25);             /**< XiaoKun (male, Chinese) */
    final public static int ivTTS_ROLE_XIAOLING             = (50011);          /**< Xiaoling  (female, Chinese) */
    final public static int ivTTS_ROLE_XIAOXUE              = (50110);          /**< Xiaoxue   (female, Chinese) */
    final public static int ivTTS_ROLE_XIAOJIE              = (50130);          /**< Xiaojie   (female, Chinese) */
    final public static int ivTTS_ROLE_XIAONUO              = (50160);          /**< Xiaonuo   (female, Chinese) */
    final public static int ivTTS_ROLE_XIAOFANG             = (51020);          /**< Xiaofang  (child, Chinese) */
    final public static int ivTTS_ROLE_YIFENG               = (51090);          /**< Yifeng    (male, Chinese) */
    final public static int ivTTS_ROLE_XIAOSHI              = (51180);          /**< Xiaoshi   (female, Chinese) */
    final public static int ivTTS_ROLE_CHONGCHONG           = (52260);          /**< Chongchong(female, Chinese) */

    final public static int ISS_TTS_PARAM_VOICE_SPEED       = (0x00000502);     /*!< Used to set the TTS voice speed */
    final public static int ISS_TTS_SPEED_MIN               = (-32768);         /*!< The slowest speed */
    final public static int ISS_TTS_SPEED_NORMAL_DEFAULT    = (0);              /*!< The normal speed by default */
    final public static int ISS_TTS_SPEED_MAX               = (+32767);         /*!< The fastest speed */

    final public static int ISS_TTS_PARAM_VOICE_PITCH       = (0x00000503);     /*!< Used to set the TTS voice pitch */
    final public static int ISS_TTS_PITCH_MIN               = (-32768);         /*!< The lowest pitch */
    final public static int ISS_TTS_PITCH_NORMAL_DEFAULT    = (0);              /*!< The normal pitch by default */
    final public static int ISS_TTS_PITCH_MAX               = (+32767);         /*!< The highest pitch */

    final public static int ISS_TTS_PARAM_VOLUME            = (0x00000504);     /*!< Used to set the TTS voice volume */
    final public static int ISS_TTS_VOLUME_MIN              = (-32768);         /*!< The minimum volume */
    final public static int ISS_TTS_VOLUME_NORMAL           = (0);              /*!< The normal volume */
    final public static int ISS_TTS_VOLUME_MAX_DEFAULT      = (+32767);         /*!< The maximum volume by default */

    final public static int ISS_TTS_PARAM_USERMODE          = (0x00000701);     /*!< user's mode */
    final public static int ISS_TTS_VOLUME_USE_NORMAL       = (0);              /*!< synthesize in the Mode of Normal */
    final public static int ISS_TTS_VOLUME_USE_NAVIGATION   = (1);              /*!< synthesize in the Mode of Navigation */
    final public static int ISS_TTS_VOLUME_USE_MOBILE       = (2);              /*!< synthesize in the Mode of Mobile */
    final public static int ISS_TTS_VOLUME_USE_EDUCATION    = (3);              /*!< synthesize in the Mode of Education */
    final public static int ISS_TTS_VOLUME_USE_TV           = (4);              /*!< synthesize in the Mode of TV */

    final public static int ISS_TTS_PARAM_VOLUME_INCREASE   = (0X00000505);     /*!< volume value increase */
    final public static int ISS_TTS_VOLUME_INCREASE_MIN     = (0);              /*!< minimized volume (default) */
    final public static int ISS_TTS_VOLUME_INCREASE_MAX     = (10);             /*!< maximized volume */

    final public static int ISS_TTS_PARAM_TMP_LOG_DIR       = (0X00000606);     /*!< Set tmp log directory for debugging */

    ///< Log level.According to the requirement to combine mask.
    final public static int     ISS_TTS_PARAM_LOG_LEVEL             = (0X00000506);
    final public static String  ISS_TTS_VOLUME_LOG_LEVEL_ALL        = "-1";     /*!< all info */
    final public static String  ISS_TTS_VOLUME_LOG_LEVEL_NONE       = "0";      /*!< none*/
    final public static String  ISS_TTS_VOLUME_LOG_LEVEL_CRIT       = "1";      /*!< critical info */
    final public static String  ISS_TTS_VOLUME_LOG_LEVEL_ERROR      = "2";      /*!< error info */
    final public static String  ISS_TTS_VOLUME_LOG_LEVEL_WARNING    = "4";      /*!< warnint info */

    ///< Log output.According to the requirement to combine mask.
    final public static int     ISS_TTS_PARAM_LOG_OUTPUT            = (0X00000507);
    final public static String  ISS_TTS_VOLUME_LOG_OUTPUT_NONE      = "0";      /*!< none */
    final public static String  ISS_TTS_VOLUME_LOG_OUTPUT_FILE      = "1";      /*!< file */
    final public static String  ISS_TTS_VOLUME_LOG_OUTPUT_CONSOLE   = "2";      /*!< console（except for android） */
    final public static String  ISS_TTS_VOLUME_LOG_OUTPUT_DEBUGGER  = "4";      /*!< debugger */
    final public static String  ISS_TTS_VOLUME_LOG_OUTPUT_MSGBOX    = "8";      /*!< message box */

    ///< Log FileName
    final public static int ISS_TTS_PARAM_LOG_FILE_NAME             = (0X00000508);

    ///< TTS Mode
    final public static int ISS_TTS_PARAM_MODE                      = (0X00000509);
    final public static int ISS_TTS_MODE_LOCAL                      = (0);      /*!< local synth (default) */
    final public static int ISS_TTS_MODE_CLOUD                      = (1);      /*!< cloud synth */
    final public static int ISS_TTS_MODE_MIX                        = (2);      /*!< local and cloud hybrid synth */

    ///< cloud synth response time out (default 800ms)
    final public static int ISS_TTS_PARAM_CLOUD_RESPONSE_TIMEOUT    = (0X00000510);

    ///< message
    /** \brief  Local tts result;\n
    *          After the ISS_TTS_MSG_LocalResult message be sent, it means local tts data ready;\n
    *  \param  wParam     ISSErrID type:\n
    *                      ISS_SUCCESS: local tts daya ready.\n
    *  \param  lParam   "{\"rate\": 16000}"
    */
    final public static int ISS_TTS_MSG_LocalResult                 = (20000);
    /** \brief  Cloud tts result;\n
               After the ISS_TTS_MSG_CloudResult message be sent, if wParam type is ISS_SUCCESS, it means cloud tts data ready;\n
    *  \param  wParam     ISSErrID type:\n
    *                      ISS_SUCCESS: cloud tts daya ready.\n
    *                      ISS_ERROR_TIME_OUT: cloud tts timeout.\n
                           ISS_ERROR_GENERAL: cloud tts error. \n
    *  \param  lParam   "{\"rate\": 16000}" or "{\"rate\": 24000}" or NULL
    */
    final public static int ISS_TTS_MSG_CloudResult                 = (20001);
    /** \brief  local audio buffer empty, detect the msg after set parameter ISS_TTS_PARAM_NEEDTOSTOP(value = 1) when need to weaken tts pop;\n
    *  \param  wParam     not used \n
    *  \param  lParam     not used, default value is NULL
    */
    final public static int ISS_TTS_MSG_ENDDATA                     = (20002);



    public static native synchronized int initRes(String resDir, int mode);

    public static native synchronized int unInitRes();

    public static native synchronized void create(NativeHandle nativeHandle, ITtsListener iTtsListener);
    
    public static native synchronized void destroy(NativeHandle nativeHandle);

    public static native synchronized void setParam(NativeHandle nativeHandle, int param, int value);

    public static native synchronized void setParamEx(NativeHandle nativeHandle, int param, String strValue);

    public static native synchronized void start(NativeHandle nativeHandle, String text);

    public static native synchronized void getAudioData(NativeHandle nativeHandle, byte[] audioBuffer, int nBytes, int[] outBytes);

    public static native synchronized void stop(NativeHandle nativeHandle);

    public static native synchronized int setMachineCode(String code);
	
	public static native synchronized int setLogCfgParam(int nParamID, String szParamValue);
}
